#if !GENERATOR

using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Xml.Serialization;
using System.Collections.Generic;

using YF.OneNote;


namespace YF.OneNote.DataTypes
{
  using Collections;


  public partial class Notes
  {
    public Notes()
    {
      _notebooks.CollectionChanged += _notebooks_CollectionChanged;
	}

    
    private void _notebooks_CollectionChanged(object sender, NotifyCollectionChangedEventArgs<Notebook> e)
    {
      switch (e.Action)
      {
        case NotifyCollectionChangedAction.Add:
        {
          foreach (Notebook item in e.NewItems)
            Children.Add(item);
        }
          break;

        case NotifyCollectionChangedAction.Remove:
        {
          foreach (Notebook item in e.OldItems)
            Children.Remove(item);
        }
          break;
      }
    }

  
    protected override bool UpdateSpecificContents(NotesHierarchyNode node, List<INotesChange> changes)
    {
	  Notes item = (Notes)node;
      bool changed = false;

      
      if (LiveSharedSections != item.LiveSharedSections)
      {
        changed = true;
		
		NotesPropertyChange propertyChange = new NotesPropertyChange();

        propertyChange.ChangeType = NoteChangeType.Changed;
        propertyChange.OldValue = _liveSharedSections;
        propertyChange.NewValue = item._liveSharedSections;
        propertyChange.PropertyName = "LiveSharedSections";
        changes.Add(propertyChange);

		
        _liveSharedSections = item._liveSharedSections;
      }

      if (UpdateCollection(Notebooks, item.Notebooks, changes))
        changed = true;

      if (OpenSections != item.OpenSections)
      {
        changed = true;
		
		NotesPropertyChange propertyChange = new NotesPropertyChange();

        propertyChange.ChangeType = NoteChangeType.Changed;
        propertyChange.OldValue = _openSections;
        propertyChange.NewValue = item._openSections;
        propertyChange.PropertyName = "OpenSections";
        changes.Add(propertyChange);

		
        _openSections = item._openSections;
      }

      if (UnfiledNotes != item.UnfiledNotes)
      {
        changed = true;
		
		NotesPropertyChange propertyChange = new NotesPropertyChange();

        propertyChange.ChangeType = NoteChangeType.Changed;
        propertyChange.OldValue = _unfiledNotes;
        propertyChange.NewValue = item._unfiledNotes;
        propertyChange.PropertyName = "UnfiledNotes";
        changes.Add(propertyChange);

		
        _unfiledNotes = item._unfiledNotes;
      }


      return changed;
    }
  }
}

#endif